#!/bin/sh

uci -q batch <<-EOF >/dev/null
	delete ucitrack.@adbyby[-1]
	add ucitrack adbyby
	set ucitrack.@adbyby[-1].init=adbyby
	commit ucitrack
	delete firewall.adbyby
	set firewall.adbyby=include
	set firewall.adbyby.type=script
	set firewall.adbyby.path=/usr/share/adbyby/firewall.include
	set firewall.adbyby.reload=1
	delete firewall.adblock
  add firewall rule
  rename firewall.@rule[-1]="adblock"
  set firewall.@rule[-1].name="adblock"
  set firewall.@rule[-1].target="DROP"
  set firewall.@rule[-1].src="wan"
  set firewall.@rule[-1].proto="tcp"
  set firewall.@rule[-1].dest_port="8118"
	commit firewall
EOF

mkdir -p /etc/dnsmasq.d

/etc/init.d/adbyby stop
/etc/init.d/adbyby enable

rm -f /tmp/luci-indexcache
exit 0
